package com.CoreryBlack.service.Impl;
/**
 * @Description ReportService
 * @Author CoreryBlack
 * @Date 2024-09-19
 */

import com.CoreryBlack.Mapper.ClazzMapper;
import com.CoreryBlack.Mapper.EmpMapper;
import com.CoreryBlack.Mapper.StudentMapper;
import com.CoreryBlack.po.CountData;
import com.CoreryBlack.po.JobOption;
import com.CoreryBlack.service.ClazzService;
import com.CoreryBlack.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {


    @Autowired
    private ClazzService clazzService;
    @Autowired
    private ClazzMapper clazzMapper;

    @Override
    public CountData countStudentCountData() {
        List<Map<String,Object>> list = clazzMapper.countStudentCountData();
        List<Object> clazzList = list.stream().map(map -> map.get("clazzList")).collect(Collectors.toList());
        List<Object> dataList = list.stream().map(map -> map.get("dataList")).collect(Collectors.toList());
        return new CountData(clazzList,dataList);
    }
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Map> getStudentDegreeData() {
        return studentMapper.getStudentDegreeData();
    }

    @Autowired
    private EmpMapper empMapper;
    @Override
    public JobOption empJobData() {

        List<Map> mapList = empMapper.empJobData();

        List<Object> jobList = mapList.stream().map(map -> map.get("job")).collect(Collectors.toList());

        List<Object> countList = mapList.stream().map(map -> map.get("count")).collect(Collectors.toList());

        JobOption jobOption = new JobOption(jobList, countList);

        return jobOption;
    }

    @Override
    public List<Map<String, Integer>> empGenderData() {

        return empMapper.empGenderData();
    }
}